package com.kingstar.ceres.data.handler;

import com.kingstar.ceres.data.constant.FileImportConstants;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public abstract class AbstractDataHandler {

    public void clearData(String tableName,String dataDate,int strategy){
        if(FileImportConstants.CLEAR_NONE==strategy){
            log.info("clear none,tableName:{}",tableName);
            return;
        }
        if (FileImportConstants.CLEAR_ALL==strategy){
            deleteAll(tableName);
            return;
        }
        if (FileImportConstants.CLEAR_CUR_DAY==strategy){
            deleteByTableAndDate(tableName,dataDate);
        }
    }
    public void clearDataStr(String tableName,String dataDate,int strategy){
        if(FileImportConstants.CLEAR_NONE==strategy){
            log.info("str clear none,tableName:{}",tableName);
            return;
        }
        if (FileImportConstants.CLEAR_ALL==strategy){
            deleteAll(tableName);
            return;
        }
        if (FileImportConstants.CLEAR_CUR_DAY==strategy){
            deleteByTableAndDateStr(tableName,dataDate);
        }
    }

    protected abstract void deleteByTableAndDate(String tableName, String dataDate);

    protected abstract void deleteByTableAndDateStr(String tableName, String dataDate);

    protected abstract void deleteAll(String tableName);
}
